<?php
/*
 * @Author: your name
 * @Date: 2020-05-22 10:14:16
 * @LastEditTime: 2020-05-26 10:16:55
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /v3/application/adminapiv3/controller/attackLogManage/screeningLogManage/ScreeningLogController.php
 */ 
namespace app\adminapiv3\controller\attackLogManage\screeningLogManage;

use app\adminapiv3\controller\Base;
use app\adminapiv3\service\attackLogManage\AttackLogService;
use app\adminapiv3\service\attackLogManage\fileLogManage\FileLogService;
use app\adminapiv3\service\attackLogManage\fileLogManage\ScreeningLogService ;

class ScreeningLogController extends Base
{
    /**
     * @name: 列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 10:18:56
     */
    function list ()
    {
        $input['attack_dest'] = $this->filterInput('attack_dest', 'get');//主机名
        $input['path'] = $this->filterInput('path', 'get');//查杀路径
        $input['atime'] = $this->filterInput('atime', 'get');//攻击时间
        $input['level'] = $this->filterInput('level', 'get');//风险级别
        $input['handle'] = $this->filterInput('handle', 'get');//处理结果

        $input['limit'] = $this->filterInput('limit', 'get', 10);//
        $ScreeningLogService = new ScreeningLogService();
        $data = $ScreeningLogService->list($input);

        $this->jsonOutPut($data);
    }

    /**
     * @name: 批量删除
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 10:54:26
     */
    function bulkDelete ()
    {
        global $logContent;
        $logContent = '批量删除查杀日志';

        $id_s = $this->filterInput('id*', 'post');//删除id
        
        $FileLogService = new FileLogService();
        $FileLogService->delete($id_s);

        $this->jsonOutPut();
    }

    /**
     * @name: 清空所有
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 10:54:45
     */
    function clear ()
    {
        global $logContent;
        $logContent = '清空查杀日志';

        $FileLogService = new FileLogService();
        $FileLogService->clear();

        $this->jsonOutPut();
    }

    /**
     * @name: 文件恢复
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 13:25:06
     */
    function fileReset ()
    {
        global $logContent;
        $logContent = '查杀日志文件恢复';

        $id = $this->filterInput('id*', 'post');
        $host_id = $this->filterInput('host_id*', 'post');

        $FileLogService = new FileLogService();
        $FileLogService->fileRest($id, $host_id);

        $this->jsonOutPut([], true);

        //下发文件恢复规则
        $this->Async('Defense', 'Recoverys', ['id' => $id]);
    }

    /**
     * @name: 数据包
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-05-22 09:59:47
     */
    function dataPackage ()
    {
        $event_id = $this->filterInput('event_id*', 'post');//事件id
        $host_id = $this->filterInput('host_id*', 'post');//主机id
        $atime = $this->filterInput('atime*', 'post');//攻击时间

        $server = new FileLogService();
        $data = $server->dataPackage($host_id, $event_id, $atime);
        
        $this->jsonOutPut($data);
    }

}